package com.sy.blog.controller;

import com.sy.blog.service.SysUserService;
import com.sy.blog.vo.Result;
import jdk.nashorn.internal.parser.Token;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("users")
public class UserController {

    @Autowired
    private SysUserService sysUserService;

    /**
     *  用户登录成功时根据前端的token来判断是否
     *  跳转到登录成功的页面，返回用户的信息
     *  参数token要用String类型而不是Token类型
     */
    @GetMapping("currentUser")
    public Result loginCheck(@RequestHeader("Authorization") String token) {
        return sysUserService.findUserByToken(token);
    }
}
